package com.example.demo.controller;

import com.example.demo.commons.Result;
import com.example.demo.vo.LoginVO;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

import static com.example.demo.commons.LoginConstants.*;

/**
 * @Author linjl
 * @Date 2023-06-17
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @PostMapping
    public Result<Map<String, String>> login(@RequestBody LoginVO loginVOBean){
        if (loginVOBean.verify(DEMO_ACCOUNT, DEMO_PASSWORD)) {
            Map<String, String> data = new HashMap<>();
            data.put("token", DEMO_TOKEN);
            return Result.success(data);
        }else {
            return Result.error("账号不存在或密码错误");
        }
    }

}
